import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
	list = '/coupleUser/users',
	save = '/coupleUser/user/add',
	edit = '/coupleUser/user/edit',
	leaderAddOrUpdate = '/coupleUser/user/addOrUpdateLeaderInfo',
	updateCityApi = '/coupleUser/user/city/userBindOrUpdateCity',
	updateSchoolApi = '/coupleUser/user/school/userBindOrUpdateSchool',
	updateRoleApi = '/coupleUser/userBindOrUpdateRole',
	updateInviteIdApi = '/coupleUser/user/updateInviteId',
	selectCityByUserId = '/coupleUser/user/city/selectCityByUserId',
	selectSchoolByUserId = '/coupleUser/user/school/selectSchoolByUserId',
	selectTagsByUserId = '/coupleUser/user/Tags/selectTagsByUserId',
	updateShopDealerInfo = '/coupleUser/user/updateShopDealerInfo',
	addCouponToUser = '/coupleUser/user/addCouponToUser',
	deleteOne = '/coupleUser/user/delete',
	deleteBatch = '/coupleUser/deleteBatch',
	/* importExcel = '/coupleUser/importExcel',
	 exportXls = '/coupleUser/exportXls', */
	coupleLeaderContractList = '/coupleUser/listCoupleLeaderContractByMainId',
	coupleLeaderContractSave = '/coupleUser/addCoupleLeaderContract',
	coupleLeaderContractEdit = '/coupleUser/editCoupleLeaderContract',
	coupleLeaderContractDelete = '/coupleUser/deleteCoupleLeaderContract',
	coupleLeaderContractDeleteBatch = '/coupleUser/deleteBatchCoupleLeaderContract',
	coupleUserFinanceList = '/coupleUser/listCoupleUserFinanceByMainId',
	coupleUserFinanceSave = '/coupleUser/addCoupleUserFinance',
	coupleUserFinanceEdit = '/coupleUser/editCoupleUserFinance',
	coupleUserFinanceDelete = '/coupleUser/deleteCoupleUserFinance',
	coupleUserFinanceDeleteBatch = '/coupleUser/deleteBatchCoupleUserFinance',
	coupleUserDiscountCouponList = '/coupleUser/listCoupleUserDiscountCouponByMainId',
	coupleUserDiscountCouponSave = '/coupleUser/addCoupleUserDiscountCoupon',
	coupleUserDiscountCouponEdit = '/coupleUser/editCoupleUserDiscountCoupon',
	coupleUserDiscountCouponDelete = '/coupleUser/deleteCoupleUserDiscountCoupon',
	coupleUserDiscountCouponDeleteBatch = '/coupleUser/deleteBatchCoupleUserDiscountCoupon',
	coupleAccountChangeRecordList = '/user/coupleAccountChangeRecord/list',
	coupleAccountChangeRecordSave = '/user/coupleAccountChangeRecord/addCoupleAccountChangeRecord',
	coupleAccountChangeRecordEdit = '/user/coupleAccountChangeRecord/editCoupleAccountChangeRecord',
	coupleAccountChangeRecordDelete = '/user/coupleAccountChangeRecord/delete',
	coupleAccountChangeRecordDeleteBatch = '/user/coupleAccountChangeRecord/deleteBatchCoupleAccountChangeRecord',
	coupleUserStrokeBindingRecordList = '/coupleUser/listCoupleUserStrokeBindingRecordByMainId',
	coupleUserStrokeBindingRecordSave = '/coupleUser/addCoupleUserStrokeBindingRecord',
	coupleUserStrokeBindingRecordEdit = '/coupleUser/editCoupleUserStrokeBindingRecord',
	coupleUserStrokeBindingRecordDelete = '/coupleUser/deleteCoupleUserStrokeBindingRecord',
	coupleUserStrokeBindingRecordDeleteBatch = '/coupleUser/deleteBatchCoupleUserStrokeBindingRecord',
	//修改角色
	updateUserRole = '/coupleUser/user/updateUserRole',
	//修改角色状态
	updateUserStatus = '/coupleUser/user/updateStatus',

}


/**
 * 列表接口
 * @param params
 */
export const coupleUserStrokeBindingRecordList = (params) => {
	if (params['coupleUserId']) {
		return defHttp.get({ url: Api.coupleUserStrokeBindingRecordList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const coupleUserStrokeBindingRecordDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.coupleUserStrokeBindingRecordDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const coupleUserStrokeBindingRecordDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.coupleUserStrokeBindingRecordDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const coupleUserStrokeBindingRecordSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.coupleUserStrokeBindingRecordEdit : Api.coupleUserStrokeBindingRecordSave;
	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const coupleUserStrokeBindingRecordImportUrl = '/user/coupleUser/importCoupleUserStrokeBindingRecord'

/**
 * 导出
 */
export const coupleUserStrokeBindingRecordExportXlsUrl = '/user/coupleUser/exportCoupleUserStrokeBindingRecord'
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
	defHttp.get({ url: Api.list, params });

/**
 * 删除单个
 */
export const deleteOne = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 修改用户角色
 */
export const updateUserRole = (params, isUpdate) => {

	return defHttp.post({ url: Api.updateUserRole, params });
}
export const updateInviteId = (params, isUpdate) => {



	return defHttp.post({ url: Api.updateInviteIdApi, params });
}
/**
 * 修改用户状态
 */
export const updateUserStatus = (params, handleSuccess) => {

	return defHttp.post({ url: Api.updateUserStatus, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.edit : Api.save;
	let extInfors = {
		remark: params.remark || " ",
		realName: params.realname || ' '
	}
	params.extInfors = JSON.stringify(extInfors)

	return defHttp.post({ url: url, params });
}
export const addCouponApi = (params) => {
	return defHttp.post({ url: Api.addCouponToUser, params });
}
export const updateShopDealer = (params, isUpdate) => {
	let extInfors = {
		remark: params.remark || ' ',
		userName: params.userName || ' '
	}
	params.extInfors = JSON.stringify(extInfors)

	return defHttp.post({ url: Api.updateShopDealerInfo, params });
}
export const updateRoleApi = (params) => {
	return defHttp.post({ url: Api.updateRoleApi, params });
}
export const updateSchoolApi = (params) => {
	return defHttp.post({ url: Api.updateSchoolApi, params });
}
export const updateCityApi = (params) => {
	return defHttp.post({ url: Api.updateCityApi, params });
}

/**
 * 列表接口
 * @param params
 */
export const coupleLeaderContractList = (params) => {
	if (params['leaderId']) {
		return defHttp.get({ url: Api.coupleLeaderContractList, params });
	}
	return Promise.resolve({});
}

export const selectTagsByUserId = (params) => {
	return defHttp.get({ url: Api.selectTagsByUserId, params });
}
export const selectCityByUserId = (params) => {
	return defHttp.get({ url: Api.selectCityByUserId, params });
}
export const selectSchoolByUserId = (params) => {
	return defHttp.get({ url: Api.selectSchoolByUserId, params });
}
/**
 * 删除单个
 */
export const coupleLeaderContractDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.coupleLeaderContractDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const coupleLeaderContractDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.coupleLeaderContractDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 领队和
 */
export const leaderAddOrUpdate = (params, isUpdate) => {
	let extinfors = {
		introduceMyself: params.introduceMyself,
		wchatnum: params.wchatnum,
		emergencyContact: params.emergencyContact,
		emergencyPhone: params.emergencyPhone,
		college: params.college,
		address: params.address,
		idCardA: params.idCardA,
		idCardB: params.idCardB,
		guideCertificate: params.guideCertificate,
		aboutLeader: params.aboutLeader,
		aboutTrip: params.aboutTrip,
		aboutRout: params.aboutRout,
		aboutExp: params.aboutExp,
		selfEval: params.selfEval,
		guideNumber: params.guideNumber
	}
	params.extInfors = JSON.stringify(extinfors)


	return defHttp.post({ url: Api.leaderAddOrUpdate, params });
}


/**
 * 保存或者更新
 * @param params
 */
export const coupleLeaderContractSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.coupleLeaderContractEdit : Api.coupleLeaderContractSave;
	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const coupleLeaderContractImportUrl = '/coupleUser/importCoupleLeaderContract'

/**
 * 导出
 */
export const coupleLeaderContractExportXlsUrl = '/coupleUser/exportCoupleLeaderContract'
/**
 * 列表接口
 * @param params
 */
export const coupleUserFinanceList = (params) => {
	if (params['userId']) {
		return defHttp.get({ url: Api.coupleUserFinanceList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const coupleUserFinanceDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.coupleUserFinanceDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const coupleUserFinanceDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.coupleUserFinanceDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const coupleUserFinanceSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.coupleUserFinanceEdit : Api.coupleUserFinanceSave;
	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const coupleUserFinanceImportUrl = '/coupleUser/importCoupleUserFinance'

/**
 * 导出
 */
export const coupleUserFinanceExportXlsUrl = '/coupleUser/exportCoupleUserFinance'
/**
 * 列表接口
 * @param params
 */
export const coupleUserDiscountCouponList = (params) => {
	if (params['userId']) {
		return defHttp.get({ url: Api.coupleUserDiscountCouponList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const coupleUserDiscountCouponDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.coupleUserDiscountCouponDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const coupleUserDiscountCouponDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.coupleUserDiscountCouponDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const coupleUserDiscountCouponSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.coupleUserDiscountCouponEdit : Api.coupleUserDiscountCouponSave;
	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const coupleUserDiscountCouponImportUrl = '/coupleUser/importCoupleUserDiscountCoupon'

/**
 * 导出
 */
export const coupleUserDiscountCouponExportXlsUrl = '/coupleUser/exportCoupleUserDiscountCoupon'
/**
 * 列表接口
 * @param params
 */
export const coupleAccountChangeRecordList = (params) => {
	if (params['userId']) {
		return defHttp.get({ url: Api.coupleAccountChangeRecordList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const coupleAccountChangeRecordDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.coupleAccountChangeRecordDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const coupleAccountChangeRecordDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.coupleAccountChangeRecordDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const coupleAccountChangeRecordSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.coupleAccountChangeRecordEdit : Api.coupleAccountChangeRecordSave;
	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const coupleAccountChangeRecordImportUrl = '/coupleUser/importCoupleAccountChangeRecord'

/**
 * 导出
 */
export const coupleAccountChangeRecordExportXlsUrl = '/coupleUser/exportCoupleAccountChangeRecord'